package controller;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class DoCheck {
	public static boolean doCheckEmail(String email) {
		String regex = "^[_A-Za-z0-9-]+(\\.[_A-Za-z0-9-]+)*@[A-Za-z0-9]+(\\.[A-Za-z0-9]+)*(\\.[A-Za-z]{2,})$";
		Pattern patern = Pattern.compile(regex);
		Matcher matcher = patern.matcher(email);
		return matcher.matches();
	}

	public boolean doCheckPhone(String phone) {
		if (phone.length() == 10) {
			Pattern pattern = Pattern.compile("0\\d{9}");
			Matcher sdtmat = pattern.matcher(phone);
			return sdtmat.matches();
		} else if (phone.length() == 11) {
			Pattern sdtpat = Pattern.compile("0\\d{10}");
			Matcher sdtmat = sdtpat.matcher(phone);
			return sdtmat.matches();
		}
		return false;
	}

	public boolean doCheckPerId(String id) {
		Pattern pattern = Pattern.compile("^[a-z0-9_-]{3,15}$");
		Matcher sdtmat = pattern.matcher(id);
		return sdtmat.matches();
	}

	public static boolean checkNumber(String s) {
		Pattern p = Pattern.compile("\\d");
		Matcher m = p.matcher(s);
		if (m.matches()) {
			return true;
		}
		return false;
	}
}
